package com.shujia.flink.tf

import org.apache.flink.api.common.functions.MapFunction
import org.apache.flink.streaming.api.scala._

object Demo1Map {
  def main(args: Array[String]): Unit = {
    val env: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment


    //基于集合构建ds，有界流
    val ds: DataStream[Int] = env.fromCollection(List(1,2,3,4,5,6,7,8,98))

    //scala语言的方式
    val ds1: DataStream[Int] = ds.map(_*2)

    //java语言的方式

    val ds2: DataStream[Int] = ds.map(new MapFunction[Int,Int] {
      override def map(t: Int): Int = {
        t * 2
      }
    })

    ds2.print()

    env.execute()
  }
}
